using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace IRCEngine
{
	public sealed class Command : MarshalByRefObject
	{
		private static readonly Regex exCommand = new Regex("^(\\w+|\\d{3})$", RegexOptions.Compiled);

		private static readonly Regex exName = new Regex("^\\w+$", RegexOptions.Compiled);

		private static readonly Regex exCode = new Regex("^\\d{3}$", RegexOptions.Compiled);

		private String data;

		public bool ValidCommand
		{
			get
			{
				return exCommand.IsMatch(data);
			}
		}

		public bool NumericCommand
		{
			get
			{
				return exCode.IsMatch(data);
			}
		}

		public String CommandName
		{
			get
			{
				if (exName.IsMatch(data))
					return data;
				return null;
			}
		}

		public int CommandValue
		{
			get
			{
				if (exCode.IsMatch(data))
					return Convert.ToInt32(data);
				return -1;
			}
		}

		public Command(String command)
		{
			data = command;
		}
	}
}
